#pragma GCC optimize(3)
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=13;
typedef long long LL;
const LL mod=1e9+7;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
int a[maxn],tot=0,now;
LL dp[maxn][maxn];
LL dfs(int pos,LL cnt,bool lead,bool limit){
   if(pos==0) return cnt;
   if(!limit&&dp[pos][cnt]!=-1) return dp[pos][cnt];
   int bound=(limit?a[pos]:9);
   LL ans=0;
   for(int i=0;i<=bound;++i){
       if(lead&&i==0){
            ans=(ans+dfs(pos-1,cnt,1,i==bound&&limit)%mod)%mod;
       }
       else if(lead&&(i!=0)){
            ans=(ans+dfs(pos-1,(i==now?cnt+1:cnt),0,i==bound&&limit)%mod)%mod;
       }
       else{
            ans=(ans+dfs(pos-1,(i==now?cnt+1:cnt),0,i==bound&&limit)%mod)%mod;
       }
   }
   if(!limit&&!lead) {
        dp[pos][cnt]=ans;
        //cout<<"pos="<<pos<<" "<<"cnt="<<cnt<<endl;
   }
   return ans;
}
inline LL solve(LL x){
   memset(dp,-1,sizeof(dp));
   tot=0;
   while(x){
      a[++tot]=x%10;x/=10;
   }
   return dfs(tot,0,1,1)%mod;
}
int main(void){
   	int q;scanf("%d",&q);
    while(q--){
        LL l,r;l=read();r=read();
        LL num1=0;LL num2=0;
        for(LL i=1;i<=9;++i){
            now=i;
            num1=(num1+solve(r)%mod*i%mod)%mod;
            num2=(num2+solve(l-1)%mod*i%mod)%mod;
        }
        printf("%lld\n",num1-num2);
    }
   	return 0;
}
